package Matches;

public class demo8 {
    public static void main(String[] args) {
        String regex1 = "(.).+\\1";
        System.out.println("a123a".matches(regex1));
        System.out.println("%546654%".matches(regex1));
        System.out.println("----------------------");
        String regex2 = "(.+)(.+)(\\1)";
        System.out.println("abc123416abc".matches(regex2));
        System.out.println("%$#1565151%$#".matches(regex2));
        System.out.println("456789456".matches(regex2));
        System.out.println("abc123abd".matches(regex2));
        System.out.println("-----------------------");
        String regex3 = "((.)\\2*).+\\1";
        System.out.println("aaa123aaa".matches(regex3));
        System.out.println("###146565###".matches(regex3));
        System.out.println("abc123abc".matches(regex3));
        System.out.println("fff789fff".matches(regex3));
        System.out.println("***4561***".matches(regex3));
        System.out.println("----------------------------");
        String s = "我要学学编编编程程程程";
        String result = s.replaceAll("(.)\\1+", "$1");
        System.out.println(result);
    }
}
